#pragma once

#include "fxcc/core/MetaCache.h"
#include "fxcc/yml/Serializer.h"

struct BaseImporter
{
	static std::string m_LibraryPath;

	static std::string m_AssertPath;

	std::string m_Name;

	BaseImporter();

	std::string GetMetaFile(const std::string& path) const
	{
		fs::path _p = fs::path(".meta") / fxcc::FileUtil::getTargetPath(path, m_Name, ".meta");
		return _p.string();
	}
	bool HasImportFile(const std::string& p) const;

	bool CreateImportMeta(const std::string& path) const;

	void ImportDir(const fxcc::Dir& dir, bool inc = true);

	virtual bool ImportFile(const fxcc::File& file) { assert("base importer"); return false; }

	virtual bool ImportFileInc(const fxcc::File& file, bool inc) { 
	
		if (inc && HasImportFile(file.m_RelativePath))
		{
			ztclog::info("has import the file %s", file.m_RelativePath.c_str());
			return true;
		}
		else
		{
			ztclog::info("it a new import task file %s", file.m_RelativePath.c_str());

			if (ImportFile(file))
			{
				CreateImportMeta(file.m_RelativePath);
				return true;
			}
			return false;
		}
	}

};